package com.carpedil.shirodemo.common.util;

import lombok.Data;

import java.io.Serializable;

/** @author Administrator */
@Data
public class ResultVO implements Serializable {
  private Integer code;
  private Integer status;
  private String message;
  private Object data;

  public ResultVO(ResultCode resultCode, Object data) {
    this.code = resultCode.status();
    this.status = resultCode.status();
    this.message = resultCode.message();
    this.data = data;
  }

  public ResultVO(Integer status, String message) {
    this.code = status;
    this.status = status;
    this.message = message;
  }

  public ResultVO(ResultCode resultCode) {
    this.code = resultCode.status();
    this.status = resultCode.status();
    this.message = resultCode.message();
  }

  /** 返回成功 */
  public static ResultVO success() {
    return new ResultVO(ResultCode.SUCCESS);
  }
  /** 返回成功 */
  public static ResultVO success(Object data) {
    return new ResultVO(ResultCode.SUCCESS, data);
  }
  /** 返回失败 */
  public static ResultVO fail(ResultCode resultCode) {
    return new ResultVO(resultCode);
  }
  /** 返回失败 */
  public static ResultVO fail(ResultCode resultCode, Object data) {
    return new ResultVO(resultCode, data);
  }

  /** 返回失败 */
  public static ResultVO fail(Integer status, String message) {
    return new ResultVO(status, message);
  }
}
